//part1:C03:ex3.24.2.cpp 
//vector with 10 elements. sum of first and last element.
#include <iostream>
#include <vector>

int main(void)
{
    using namespace std;
    vector<int > vInt;
    int iVal;
    cout << "Enter some integers\n";
    while (cin >> iVal)
    {
        vInt.push_back(iVal);
    }
    if (vInt.cbegin() == vInt.cend())
    {
        cout << "No elements!" << endl;
        return -1;
    }

    cout << "sum of first and last elements is :\n";
    auto beg= vInt.begin();
    auto end = vInt.end();

    for (auto it = beg; it != beg + (end - beg)/2; it++)
    {
        cout << (*it + *(beg + (end - it) - 1)) << " ";
        if ((it - beg + 1) % 5 == 0)
        {
            cout << endl;
        }
    }
    if (vInt.size() % 2 != 0)
    {
        cout << *(beg + (end - beg) / 2);
    }

    return 0;
}
